Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): deno init --lib #22499

Merged
merged 11 commits into from
Jul 10, 2024
Merged

feat(cli): deno init --lib #22499

merged 11 commits into from
Jul 10, 2024

Conversation

muddlebee
Copy link
Contributor

@muddlebee muddlebee marked this pull request as draft February 20, 2024 18:20
@muddlebee muddlebee marked this pull request as ready for review February 20, 2024 18:22
@littledivy
Copy link
Member

Thanks for the PR! Can you please fix format errors? https://github.com/denoland/deno/actions/runs/8005137443/job/21863912560?pr=22499#step:26:44

cli/tools/init/templates/deno_lib.json Outdated Show resolved Hide resolved
cli/tools/init/mod.rs Outdated Show resolved Hide resolved
@muddlebee
Copy link
Contributor Author

muddlebee commented Feb 22, 2024

@littledivy fixed

Copy link
Member

@littledivy littledivy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@littledivy littledivy changed the title fix(cli): deno init should add name, version and exports fields to deno.json feat(cli): deno init --lib Feb 23, 2024
"version": "1.0.0",
"exports": {},
"tasks": {
"dev": "deno run --watch main.ts"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: Why does a library default to having a main.ts? That sounds more like an application thing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, probably better to do lib.ts instead

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe even better, mod.ts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed this to mod.ts, which is the default entrypoint name for libraries in Deno. I also changed the subcommand to deno test, rather than deno run, as it's a for a library, rather than a script. Happy to change, if there are better suggestions.

@bartlomieju bartlomieju added this to the 1.42 milestone Mar 6, 2024
Comment on lines +55 to +57
let project_name = dir
.file_name()
.unwrap_or_else(|| dir.as_os_str())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be problematic - I don't think all directories are valid JSR specifiers, but maybe fine for the first pass and could be improved in the future.

"version": "1.0.0",
"exports": {},
"tasks": {
"dev": "deno run --watch main.ts"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, probably better to do lib.ts instead

@bartlomieju bartlomieju modified the milestones: 1.42, 1.43 Mar 27, 2024
@bartlomieju bartlomieju modified the milestones: 1.43, 1.44 May 5, 2024
@iuioiua iuioiua self-assigned this Jun 17, 2024
@dsherret dsherret modified the milestones: 1.44, 1.45 Jul 9, 2024
@dsherret dsherret assigned dsherret and unassigned iuioiua Jul 9, 2024
Comment on lines 80 to 86
r#"import { assertEquals } from "jsr:@std/assert";
import { add } from "./main.ts";

Deno.test(function addTest() {
assertEquals(add(2, 3), 5);
});
"#,
Copy link
Member

@bartlomieju bartlomieju Jul 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now these don't get auto-formatted 😛

@muddlebee
Copy link
Contributor Author

nice

@dsherret dsherret merged commit ff5163a into denoland:main Jul 10, 2024
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants